home *** CD-ROM | disk | FTP | other *** search
/ PC Media 22 / PC MEDIA CD22.iso / share / udos / gus195 / gus_19.exe / rar / GUS_WCFG.PAS < prev    next >
Pascal/Delphi Source File  |  1995-03-15  |  7KB  |  157 lines

  1. {$A+,B-,D-,E-,F-,I+,L-,N-,O-,R+,S+,V-}
  2. {$IFDEF VER60}
  3.   {$G-,X-}
  4. {$ENDIF}
  5. {$IFDEF VER70}
  6.   {$G-,P-,Q-,T-,X-,Y-}
  7. {$ENDIF}
  8. {$M 1024, 0, 0}
  9.  
  10. program GUS_WriteConfig;    { Append or update configuration }
  11.                             { information to or in GUS.EXE    for v1.95 !!!  }
  12. uses DOS;
  13.  
  14. type
  15.     FNameStr = string[12];
  16.  
  17.     ArcType = (ARC, ARp, ARJ, DWC, HA,  HAP, HPK, HYP, LZH,
  18.                PAK, RAR, SQZ, UC2, ZIP, ZOO);
  19.     ArcCmds = (Extract, Replace, Display, Test, Contents);
  20.  
  21.     ArcData = record
  22.                 Ext : string[3];
  23.                 Prog: FNameStr;
  24.                 Cmd : array [ArcCmds] of string[10];
  25.                 Pth,
  26.                 Pwd : string[5];
  27.               end;
  28.  
  29.     ArcCfg  = record
  30.                 Marker  : longint;
  31.                 VirDet  : record
  32.                            Prog: FNameStr;
  33.                            Cmd : string[20];
  34.                           end;
  35.                 ArcTable: array [ArcType] of ArcData;
  36.               end;
  37.  
  38. const
  39.     GUSname     = 'GUS.EXE';
  40.     CfgMarker   = $C3535547;       {'GUS'+chr(195)}
  41.     Unsupported = '**********';
  42.     ArcInfo     : ArcCfg
  43.     = (Marker   : CfgMarker;
  44.        VirDet   : (  Prog: 'SCAN    .EXE'; Cmd: '. /NOMEM            ');
  45.                                           {      ^^^^^^^^ scan CURRENT dir for viruses! }
  46.        ArcTable :                         {     Extract       Replace       Display       Test          Contents    }
  47.        ((Ext: 'ARC'; Prog: 'PKUNPAK .EXE'; Cmd:('-n        ', '-r        ', '-c        ', '-t        ', '-v        ');
  48.                                            Pth: Unsupported;
  49.                                            Pwd: 'g    '     ),
  50.         (Ext: 'A7+'; Prog: 'XARC    .EXE'; Cmd:('          ', '/o        ', Unsupported , Unsupported , Unsupported );
  51.                                            Pth: Unsupported;
  52.                                            Pwd: '/g   '     ),
  53.         (Ext: 'ARJ'; Prog: 'ARJ     .EXE'; Cmd:('e -uy     ', 'e -y      ', 'p         ', 't         ', 'l         ');
  54.                                            Pth: '<x   '    ;
  55.                                            Pwd: ' -g  '     ),
  56.         (Ext: 'DWC'; Prog: 'DWC     .EXE'; Cmd:('xow       ', 'xw        ', 'p         ', 't         ', 'v         ');
  57.                                            Pth: 'r    '    ;
  58.                                            Pwd: 'g    '     ),
  59.         (Ext: 'HA '; Prog: 'HA      .EXE'; Cmd:('et        ', 'ety       ', Unsupported , 't         ', 'l         ');
  60.                                            Pth: '<x   '    ;
  61.                                            Pwd: Unsupported ),
  62.         (Ext: 'HAP'; Prog: 'PAH     .EXE'; Cmd:('e         ', 'e         ', Unsupported , Unsupported , 'l         ');
  63.                                            Pth: Unsupported;
  64.                                            Pwd: Unsupported ),
  65.         (Ext: 'HPK'; Prog: 'HPACK   .EXE'; Cmd:('x -on     ', 'x -oa     ', 'p         ', 't         ', 'v         ');
  66.                                            Pth: ' -da '    ;
  67.                                            Pwd: ' -c  '     ),
  68.         (Ext: 'HYP'; Prog: 'HYPER   .EXE'; Cmd:('-x        ', '-xo       ', Unsupported , Unsupported , '-v        ');
  69.                                            Pth: 'p    '    ;
  70.                                            Pwd: Unsupported ),
  71.         (Ext: 'LZH'; Prog: 'LHA     .EXE'; Cmd:('e /m+     ', 'e /m+c+   ', 'p /m+     ', 't /m+     ', 'l         ');
  72.                                            Pth: 'x+   '    ;
  73.                                            Pwd: Unsupported ),
  74.         (Ext: 'PAK'; Prog: 'PAK     .EXE'; Cmd:('e/WO      ', 'e/WA      ', 'p         ', 't         ', 'l         ');
  75.                                            Pth: '/PATH'    ;
  76.                                            Pwd: '/g=  '     ),
  77.         (Ext: 'RAR'; Prog: 'UNRAR   .EXE'; Cmd:('e -u      ', 'e -o+     ', 'p         ', 't         ', 'l         ');
  78.                                            Pth: '<x   '    ;
  79.                                            Pwd: ' -p  '     ),
  80.         (Ext: 'SQZ'; Prog: 'SQZ     .EXE'; Cmd:('e /o0     ', 'e /o1     ', 'p         ', 't         ', 'l         ');
  81.                                            Pth: '<x   '    ;
  82.                                            Pwd: Unsupported ),
  83.         (Ext: 'UC2'; Prog: 'UC      .EXE'; Cmd:('E         ', 'E -F      ', '$PRF      ', 'T         ', 'V         ');
  84.                                            Pth: ' -S  '    ;
  85.                                            Pwd: Unsupported ),
  86.         (Ext: 'ZIP'; Prog: 'PKUNZIP .EXE'; Cmd:('-n        ', '-o        ', '-c        ', '-t        ', '-v        ');
  87.                                            Pth: ' -d  '    ;
  88.                                            Pwd: ' -s  '     ),
  89.         (Ext: 'ZOO'; Prog: 'ZOO     .EXE'; Cmd:('e:O       ', 'e:OS      ', 'e:p       ', 'e:N       ', 'lC        ');
  90.                                            Pth: '//   '    ;
  91.                                            Pwd: Unsupported )
  92.        )   {NOTE: if the first character of an option string is a '<', then it means that the following letter
  93.            should REPLACE the first letter of the command string and not be added to it like the other options.}
  94.       );
  95.  
  96. var
  97.     CfgData : ArcCfg;
  98.     GUSfile : file;
  99.  
  100.  
  101. procedure ReadData (var F   : file;
  102.                     var Data: ArcCfg);
  103.  begin
  104.   {$I-} reset(F, 1); {$I+}
  105.   if IOresult <> 0
  106.    then begin
  107.          writeln('Can''t open ', GUSname);
  108.          Halt(1);
  109.         end;
  110.   {$I-} seek(F, filesize(F)-sizeof(ArcCfg)); {$I+}
  111.   if IOresult <> 0
  112.    then begin
  113.          writeln('Problem: cannot seek to byte location ', filesize(F), ' - ', sizeof(ArcCfg));
  114.          Halt(1);
  115.         end;
  116.   {$I-} BlockRead(F, Data, sizeof(ArcCfg)); {$I+}
  117.   if IOresult <> 0
  118.    then begin
  119.          writeln('Problem: cannot read ', sizeof(ArcCfg), ' bytes in ', GUSname, ' at offset ', filepos(F));
  120.          Halt(1);
  121.         end;
  122.   close(F);
  123.   writeln('Reading configuration information from ', GUSname)
  124.  end; {ReadData}
  125.  
  126.  
  127. procedure AppendData (var F   : file;
  128.                       var Data: ArcCfg);
  129.  begin
  130.   Data.Marker:=CfgMarker;
  131.   reset(F, 1);
  132.   seek(F, filesize(F));
  133.   BlockWrite(F, Data, sizeof(ArcCfg));
  134.   close(F);
  135.   writeln('Appending configuration information to ', GUSname)
  136.  end; {AppendData}
  137.  
  138.  
  139. procedure UpdateData (var F   : file;
  140.                       var Data: ArcCfg);
  141.  begin
  142.   Data.Marker:=CfgMarker;
  143.   reset(F, 1);
  144.   seek(F, filesize(F)-sizeof(ArcCfg));
  145.   BlockWrite(F, Data, sizeof(ArcCfg));
  146.   close(F);
  147.   writeln('Updating configuration information in ', GUSname)
  148.  end; {UpdateData}
  149.  
  150. begin {=MAIN=}
  151.  assign(GUSfile, GUSname);
  152.  ReadData(GUSfile, CfgData);
  153.  if CfgData.Marker = CfgMarker
  154.   then UpdateData(GUSfile, ArcInfo)
  155.   else AppendData(GUSfile, ArcInfo)
  156. end.
  157.